#!/usr/bin/env python3
# Created by han on 2016/6/6
import os,sys,platform
if platform.system() == 'Windows':
    BASE_DIR = '\\'.join(os.path.dirname(__file__).split('/')[:-1])
else:
    BASE_DIR = '/'.join(os.path.dirname(__file__).split('/')[:-1])
sys.path.append(BASE_DIR)


from module import public,accout




def main():
    while True:
        frist_page = ["用户登陆", "用户管理"]
        msg = "欢迎光临我了个去银行".center(40," ")
        public.color_msg(32,msg)
        user_inp = public.user_chose(*frist_page)
        if user_inp:
            if user_inp == "1":
                login_return = accout.login_info()
                if login_return:
                    public.user_format(**login_return)      #登陆后自动显示格式化输入用户账户信息
                else:
                    continue
                while True:
                    user_menu = ["信用卡提现", "信用卡还款", "可用现金转账", "信用卡账户信息查询"]
                    user_inp = public.user_chose(*user_menu)
                    if user_inp == "1":
                            money_num = accout.before("提现",**login_return)
                            if money_num:
                                accout.out_money(money_num,**login_return)
                            else:
                                msg = "返回".center(40," ")
                                public.color_msg(33,msg)
                    elif user_inp == "2":
                        money_num = accout.before("还款",**login_return)
                        if money_num:
                            accout.back_money(money_num,**login_return)

                    elif user_inp == "3":
                        tran_user = accout.transfer_judge(**login_return)
                        if tran_user:
                            accout.transfer(tran_user,**login_return)
                    elif user_inp == "4":
                        user_name = login_return["user"]
                        user_dict = public.load_file(user_name)
                        new_user_dict = accout.ret_info(**user_dict)
                        public.user_format(**new_user_dict)

                    elif user_inp == "0":
                        break
                    # else:
                    #     msg = "输入有误请重新输入".center(40," ")
                    #     public.color_msg(31,msg)
            elif user_inp == "2":
                accout.manage()

        else:
            continue
if __name__ == '__main__':
    main()


